package pl.krzosekm.vehicleregister.backup;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import pl.krzosekm.vehicleregister.model.User;

@SuppressWarnings("serial")
public class UserViewModel extends AbstractTableModel {

	List<User> users;
	private String[] columnName = {"login","name","surname"};

//	private Class[] classes = {String.class, String.class, String.class};
	
	
	
	public UserViewModel(List<User> users) {
		super();
		this.users = users;
	}

	public int getColumnCount() {
		return columnName.length;
	}

	public int getRowCount() {
		return users.size();
	}
	
	public User getUserAt(int rowIndex) {
		return users.get(rowIndex);
	}

	public Object getValueAt(int rowIndex, int columnIndex) {
		switch(columnIndex) {
	        case 0 :
	            return users.get(rowIndex).getLogin();
	        case 1 :
	            return users.get(rowIndex).getFirstName();
	        case 2 :
	            return users.get(rowIndex).getSurname();
	        default :
	            return null;
	    }
	}
	

//	@Override
//    public Class getColumnClass(int columnIndex) {
//        return classes[columnIndex];
//    }

    @Override
    public String getColumnName(int columnIndex) {
        return columnName[columnIndex];
    }



    
    


}
